package fr.pud.client.controller.address;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import fr.pud.client.i18n.LanguagesConstants;
import fr.pud.client.images.ImagesDatabase;
import fr.pud.client.view.AddressSuggestionsFrame;

/**
 * The action which closes the suggestions frame.
 * This class could be done generic by working on JFrame.
 * Apr 8, 2012 - OSE
 * @author Simon Devineau, Adrien Hierry, Leopold Houdin, Pierre Reliquet
 *         Ecole des Mines de Nantes
 *         CloseSuggestionsAddressesFrame.java
 */
public class CloseSuggestionsAddressesFrame extends AbstractAction {
    /**
     * The default serial
     */
    private static final long       serialVersionUID = 364986916094586765L;
    /**
     * A reference to the frame which should be closed.
     */
    private AddressSuggestionsFrame frameToClose;

    /**
     * The constructor which sets up the different variable name, icon ...
     * @param frame
     *            , the frame which should be closed.
     */
    public CloseSuggestionsAddressesFrame(AddressSuggestionsFrame frame) {
        this.putValue(NAME,
                LanguagesConstants.LANGUAGE.getString(LanguagesConstants.CLOSE));
        this.putValue(SMALL_ICON, ImagesDatabase.RED_CROSS);
        this.putValue(SHORT_DESCRIPTION, LanguagesConstants.LANGUAGE
                .getString(LanguagesConstants.CLOSE_DESCRIPTION));
        this.frameToClose = frame;
    }

    /**
     * If an action is performed the frame is disposed
     */
    @Override
    public void actionPerformed(ActionEvent arg0) {
        this.frameToClose.dispose();
    }
}
